package DisplayDatas;

import java.util.*;

import DataObjects.*;
import Main.*;

public class ArticleToDisplayFull {
	private int id;
	private String title;
	private String text;
	Collection<Pair<String,Object>> metadata;
	LinkedList<TopicToDisplay> topics;
	
	public ArticleToDisplayFull(Article article,HashMap<Integer,TopicToDisplay> allTopicsInResult,HashMap<Integer,Topic> allTopics){//TODO do samething this the topics
		this.id=article.getId();
		this.text=article.getText();
//		this.metadata.add(new Pair<String, String>("writer", article.getAuthor()));//TODO not like this 22
		
		this.metadata=article.getMetadata();
		
		topics=new LinkedList<TopicToDisplay>();
		for(Topic topic : article.getTopics()){
			TopicToDisplay topicToDisplay=allTopicsInResult.get(topic);
			if (topicToDisplay==null){
				topicToDisplay=new TopicToDisplay(topic);
				allTopicsInResult.put(topic.getId(), topicToDisplay);				
			}
			topicToDisplay.addToCountFound();
			topics.add(topicToDisplay);
		}
	}
	
	public int getId() {
		return id;
	}

	public String getTitle() {
		return title;
	}

	public String getText() {
		return text;
	}
	
	public void addTopic(TopicToDisplay topic){
		topics.add(topic);
	}
	
	public Iterator<Pair<String,Object>> getMetadataIterator(){
		return metadata.iterator();
	}
	
	public Iterator<TopicToDisplay> getTopicsIterator(){
		return topics.iterator();
	}
}
